Skip to main content
GET
/
v1
/
misc
/
db
Get Db
curl --request GET \
  --url https://api.xpander.ai/v1/misc/db \
  --header 'x-api-key: <api-key>'
{
  "id": "<string>",
  "name": "<string>",
  "organization_id": "<string>",
  "connection_uri": {
    "uri": "<string>"
  }
}
Retrieve the PostgreSQL database connection details for your organization. This provides direct access to your organization’s Neon database instance.

Response

id
string
Neon project identifier
name
string
Database project name (typically org_[organization_id])
organization_id
string
Your organization UUID
connection_uri
object
Database connection details

Example Request

curl -X GET -H "x-api-key: YOUR_API_KEY" \
  https://api.xpander.ai/v1/misc/db

Example Response

{
  "id": "still-meadow-47437464",
  "name": "org_91fbe9bc-35b3-41e8-b59d-922fb5a0f031",
  "organization_id": "91fbe9bc-35b3-41e8-b59d-922fb5a0f031",
  "connection_uri": {
    "uri": "postgresql://user:password@ep-proud-credit-af01jccy.c-2.us-west-2.aws.neon.tech/xpander?channel_binding=require&sslmode=require"
  }
}

Usage Examples

Python (psycopg2)

import psycopg2
import requests

# Get connection string
response = requests.get(
    "https://api.xpander.ai/v1/misc/db",
    headers={"x-api-key": "YOUR_API_KEY"}
)
connection_uri = response.json()["connection_uri"]["uri"]

# Connect to database
conn = psycopg2.connect(connection_uri)
cursor = conn.cursor()

# Query data
cursor.execute("SELECT * FROM tasks LIMIT 10")
results = cursor.fetchall()

Node.js (pg)

const fetch = require('node-fetch');
const { Client } = require('pg');

// Get connection string
const response = await fetch('https://api.xpander.ai/v1/misc/db', {
  headers: { 'x-api-key': 'YOUR_API_KEY' }
});
const { connection_uri } = await response.json();

// Connect to database
const client = new Client({
  connectionString: connection_uri.uri
});
await client.connect();

// Query data
const result = await client.query('SELECT * FROM tasks LIMIT 10');
console.log(result.rows);

CLI (psql)

# Get connection string
CONNECTION_URI=$(curl -H "x-api-key: YOUR_API_KEY" \
  https://api.xpander.ai/v1/misc/db | jq -r '.connection_uri.uri')

# Connect with psql
psql "$CONNECTION_URI"

Database Schema

Your organization database contains tables for:
  • agents - Agent configurations and metadata
  • tasks - Task execution records
  • knowledge_bases - Knowledge base metadata
  • documents - Document records and processing status
  • users - User information and permissions
  • And more…

Security Notes

  • The connection string includes credentials - keep it secure
  • Use environment variables to store the connection string
  • Never commit connection strings to version control
  • The database is read-write - be careful with modifications
  • SSL is required for all connections

Use Cases

  • Custom analytics - Query task and agent data directly
  • Data export - Extract data for external analysis
  • Integration - Connect BI tools like Tableau, Metabase, etc.
  • Backup - Create custom backup solutions
  • Advanced queries - Perform complex SQL queries not available via API

Notes

  • This is a Neon PostgreSQL serverless database
  • Connection pooling is handled automatically
  • Database is located in AWS us-west-2 region
  • SSL mode is required for security

See Also

  • [List Tasks](/API reference/v1/tasks/list-tasks) - Query tasks via REST API
  • [List Agents](/API reference/v1/agents/list-agents) - Query agents via REST API
  • Neon Documentation - Learn more about Neon PostgreSQL

Authorizations

x-api-key
string
header
required

API Key for authentication

Response

200 - application/json

Successful Response

Represents a Neon project used in xpander.ai for managing database resources.

Attributes: id (str): Unique identifier for the Neon project. name (str): Name of the Neon project. organization_id (Optional[str]): The associated organization ID, inferred from the name if not provided. connection_uri (Optional[ConnectionURIResponse]): The connection URI for the project.

id
string
required
name
string
required
organization_id
string | null
connection_uri
object | null